// reversi.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


#include <iostream>
#include "reversigameboard.h"

using namespace std;
int main()
{
	Gameboard game;
	game.setup();
	char p;
	short r;
	short failedTime=0;
	char c;
	char select;
	int check=0;
	
	cout << "O = White" << endl
		 << "@ = Black" << endl
		 << "* = Availble moves" << endl;
		 
	game.showNextPos();
	game.display();
	while (true)
	{
		p=0;
		cout << game.currentColor() << "'s turn" << endl;
		
		while(true)
		{
		if(check==1)
			cout<<"enter u in row to undo \n";
		cout << "row: ";
		cin >> p;
		
		if(!(p == '1' || p == '2' || p == '3' || p == '4' || p == '5' || p == '6' || p == '7' || p == '8'||(p=='u'&&check==1)))
		{
			cout << "Sorry thats not a valid row" << endl;
		}
		else
		{
			switch(p)
			{
				case '1':
					r=1;
					break;
				case '2':
					r=2;
					break;
				case '3':
					r=3;
					break;
				case '4':
					r=4;
					break;
				case '5':
					r=5;
					break;
				case '6':
					r=6;
					break;
				case '7':
					r=7;
					break;
				case '8':
					r=8;
					break;
				case 'u':
					{
					check=0;
					game.undo();
					game.showNextPos();
					game.display();
					break;
					}
			}
					
			break;
		}
		}

		if(p!='u')
		{
		while(true)
		{
		cout << "column: \n";
		cin >> c;
		if(!(c=='a' || c=='b' || c=='c' || c=='d' || c=='e' || c=='f' || c=='g' || c=='h'))
			cout << "Sorry thats not a valid column" << endl;
		else
			break;
		}
		

		
		game.move(r,c);
		game.showNextPos();
		game.display();
		
		
			
			
		

		/*if(game.showNextPos() == false)
			failedTime++;

		if(failedTime == 2)
			game.gameOver();*/
			check=1;
			}

	}	
	return 0;
}


